package com.ltkj.shop.controller.mobile;

import com.ltkj.common.core.web.controller.BaseController;
import com.ltkj.common.core.web.domain.AjaxResult;
import com.ltkj.common.core.web.page.TableDataInfo;
import com.ltkj.common.security.utils.DictUtils;
import com.ltkj.shop.domain.ShopHotelRoom;
import com.ltkj.shop.domain.ShopHotelRoomType;
import com.ltkj.shop.domain.vo.DictDataVo;
import com.ltkj.shop.domain.vo.ShopHotelRoomVo;
import com.ltkj.shop.service.IShopHotelRoomService;
import com.ltkj.shop.service.IShopHotelRoomTypeService;
import com.ltkj.system.api.domain.SysDictData;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.stream.Collectors;

/**
 * 酒店房间Controller
 * 
 * @author xupf
 * @date 2023-08-29
 */
@Api(tags = "酒店房间移动端接口")
@RestController
@RequestMapping("/mobile/hotel/room")
public class ShopHotelRoomMobileController extends BaseController
{
    @Autowired
    private IShopHotelRoomService shopHotelRoomService;
    @Autowired
    private IShopHotelRoomTypeService shopHotelRoomTypeService;

    /**
     * 查询酒店房间列表
     */
    @ApiOperation("查询酒店房间列表")
    @GetMapping("/list")
    public TableDataInfo list(ShopHotelRoom shopHotelRoom)
    {
        startPage();
        List<ShopHotelRoom> list = shopHotelRoomService.selectList(shopHotelRoom);
        List<ShopHotelRoomVo> resList = list.stream().map(ShopHotelRoomVo::fromDO).collect(Collectors.toList());
        return getDataTable(resList);
    }

    /**
     * 获取酒店房间类型
     */
    @ApiOperation("获取酒店房间类型V2")
    @GetMapping("/searchType/{hotelId}")
    public AjaxResult searchTypeByHotelId(@PathVariable("hotelId") Long hotelId)
    {
        ShopHotelRoomType shopHotelRoomType = new ShopHotelRoomType();
        shopHotelRoomType.setHotelId(hotelId);
        List<ShopHotelRoomType> shopHotelRoomTypes = shopHotelRoomTypeService.selectShopHotelRoomTypeList(shopHotelRoomType);
        return AjaxResult.success(shopHotelRoomTypes);
    }

    /**
     * 获取酒店房间类型
     */
    @ApiOperation("获取酒店房间类型")
    @GetMapping("/searchType")
    public AjaxResult searchType()
    {
        List<SysDictData> list = DictUtils.getDictCache("shop_hotel_room_type");
        List<DictDataVo> resList = list.stream().map(DictDataVo::fromDO).collect(Collectors.toList());
        return AjaxResult.success(resList);
    }


    /**
     * 获取酒店房间详细信息
     */
    @ApiOperation("获取酒店房间详细信息")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(shopHotelRoomService.selectShopHotelRoomById(id));
    }

}
